#include "resamplepcmthread.h"
#include "ffmpegutils.h"
ResamplePCMThread::ResamplePCMThread(QObject *parent) : QThread(parent)
{
    init();
}

ResamplePCMThread::~ResamplePCMThread()
{

    disconnect();

    requestInterruption();

    quit();

    wait();

    qDebug() << "resamplePCMThread destroy";
}

void ResamplePCMThread::init()
{

    connect(this,&QThread::finished,this,&QThread::deleteLater);
}

void ResamplePCMThread::run()
{

//    FFMPEGUtils::resamplePCM();
//    FFMPEGUtils ffmpegUtils;
//    ffmpegUtils.resamplePCM();

    ResampleStruct in;

    in.pcm_file = "/Users/apple/Documents/ffmpeg/qt/audio/recode_pcm_1618500714.pcm";
    in.channel_layout = AV_CH_LAYOUT_STEREO;
    in.sample_format = AV_SAMPLE_FMT_FLT;
    in.sample_rate = 44100;

    ResampleStruct out;
    out.pcm_file = "/Users/apple/Documents/ffmpeg/qt/audio/recode_pcm_48000_2_16_new.pcm";
    out.channel_layout = AV_CH_LAYOUT_STEREO;
    out.sample_format = AV_SAMPLE_FMT_S16;
    out.sample_rate = 48000;

    FFMPEGUtils::resamplePCM(in,out);
}
